"use strict";

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Load = function () {
    _createClass(Load, [{
        key: "preCallback",
        value: function preCallback() {
            if (tinymce!=undefined){
                tinymce.EditorManager.editors.forEach(function(editor) {
                    var old_global_settings = tinymce.settings;
                    tinymce.settings = editor.settings;
                    tinymce.EditorManager.execCommand('mceRemoveEditor', false, editor.id);
                    tinymce.EditorManager.execCommand('mceAddEditor', false, editor.id);
                    tinymce.settings = old_global_settings;
                });
            }
        }
    }, {
        key: "callback",
        value: function callback(response, status, xhr) {
        }
    }]);

    function Load(jquery, container) {
        _classCallCheck(this, Load);

        if (null != container && undefined != container && '' != container) {
            this.container = container;
        } else {
            this.container = "#homeContent";
        }
        this.domContext = jquery;
    }

    _createClass(Load, [{
        key: "load",
        value: function load(_ref) {
            var _ref$container = _ref.container,
                container = _ref$container === undefined ? this.container : _ref$container,
                url = _ref.url,
                data = _ref.data,
                _ref$callback = _ref.callback,
                callback = _ref$callback === undefined ? this.callback : _ref$callback,
                _ref$preCallback = _ref.preCallback,
                preCallback = _ref$preCallback === undefined ? this.preCallback : _ref$preCallback;

            this.preCallback();
            this.domContext(container).load(url, data, callback);
        }
    }]);

    return Load;
}();